package cn.zhukelili.dynamincproxymodel;

import cn.zhukelili.base.GamePlayer;
import cn.zhukelili.dynamicproxy.GamePlayIH;
import cn.zhukelili.ordinaryproxy.IGamePlayer;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @Description: 场景类
 * @Auther: hongheshou
 * @Date: 2018/7/16 09:28
 */
public class Client {
    public static void main(String[] args) {
        //定义一个主题
        Subject subject = new RealSubject();
        //定义一个Handler
        InvocationHandler handler = new MyInvocationHandler(subject);
        //定义主题的代理
        Subject proxy = DynamicProxy.newProxyInstance(subject.getClass().
                getClassLoader(), subject.getClass().getInterfaces(), handler);
        //代理的行为
        proxy.doSomething("Finish");
    }
}
